<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.js"></script>
<script type="text/javascript">
    $(document).ready(function(){ 

        $(function() {
            $("#contentLeft ul").sortable({ opacity: 0.6, cursor: 'move', update: function() {
                    var order = $(this).sortable("serialize") + '&update=update'; 
                    $.post("<?php echo $this->base ?>/admin/memberplans/sorted", order, function(theResponse){
                        //  $("#contentRight").html(theResponse);
                    }); 															 
                }								  
            });
        });

    });	
</script>
<style>
    .listing_profile_field{
        clear: both;
        content: ".";
        display: block;
        height: 0;

    }
    .listing_profile_field li{
        display: inline;
        float: left;
        position: relative;
        cursor: move;
    }
    .title{
        width: 100px;
        float:left;
        margin-left: 20px;
        font-size: 14px;

    }
    .question{
        width: 200px;
        float:left;
        font-size: 14px;
        margin-left: 10px;
    }
    .title1{
        width: 100px;
        float:left;
        /*margin-left: 23px;*/

    }
    .question1{
        width: 200px;
        float:left;

        margin-left: 10px;
    }
</style>
<table width="1024px">
    <tr ><td><div  style="float:right">
                <?php 
                error_reporting(0);
                echo $this->Html->link(
                        $this->Html->image('../img/add_more.png', array('alt' => 'Add more')), array('action' => 'add'), array('escape' => false, 'class' => 'noprint')
                );
                ?></div></div></td></tr>
    <tr><td>&nbsp;</td></tr>
    <tr><td style=" background: #B0CAEA; height: 30px;">
            <div class="title"><?php echo $this->Paginator->sort("Title", 'title'); ?></div>
            <div class="question">Prices</div>
             <div class="question">Period</div>
            <div class="question">Bonus Points/Period</div>
            <div class="title">Edit</div>
            <div class="title">Delete</div>

        </td>
    <tr>

        <td>
            <div id="contentLeft">
                <ul id="ui-sortable"  class="listing_profile_field">



                    <?php $i = 0;
                    foreach ($fields as $data): 
                        
                        
                        $price=explode(',',$data['Memberplan']['price']);
                        $period=explode(',',$data['Memberplan']['period']);
                     ?>
                        <li  id="recordsArray_<?php echo $data['Memberplan']['id']; ?>"><div class="title1"><?php //echo $data['Profilefield']['order'];  ?></div>
                            <div class="title1"><?php echo $data['Memberplan']['title']; ?>&nbsp;</div>
                            <div class="question1"><?php foreach($price as $prc){  echo '&nbsp;&nbsp;'.$prc.'&nbsp;&nbsp;'; }?>&nbsp;</div>
                               <div class="question1"><?php foreach($period as $per){  echo '&nbsp;&nbsp;'.$per.'&nbsp;&nbsp;'; }?>&nbsp;</div>
                            <div class="question1"><?php echo $data['Memberplan']['points']; ?>&nbsp;/&nbsp;<?php echo $data['Memberplan']['duration']; ?></div>
                            <div class="title1"> <?php echo $this->Html->link($this->Html->image('user_edit.png', array('alt' => 'Edit', 'title' => 'edit', 'border' => '0')), array('action' => 'admin_edit', $data['Memberplan']['id']), array('escape' => false)); ?></div>
                            <div class="title1"> <?php echo $this->Html->link($this->Html->image('trash.png', array('alt' => 'Delete', 'title' => 'Delete', 'border' => '0')), array('action' => 'admin_delete', $data['Memberplan']['id']), array('escape' => false, 'onclick' => "return confirm('Are you sure you want to delete?')")); ?></div>
                        </li>
    <?php $i++;
endforeach; ?>


                </ul>
            </div>
        </td>
    <tr><td><?php
echo $this->Paginator->numbers();
?></td></tr>
</tr>
<tr>

        <td>
            <br/>
                    <?php echo $this->Form->create('Memberplan',array('action'=>'update_text')); ?>
		<table border="0" cellspacing="3" cellpadding="3">
			<tbody><tr><td>&nbsp;</td><td><span style="font-size: 15px;">Edit membership plan texts</span></td></tr>
			<?php $count=1; foreach($text as $tst) : ?>
                            <tr><td valign="top"><?php echo $count; ?>.</td><td><?php echo $this->Form->input('Memberplantext.text',array('label'=>'','style'=>'width: 400px; height: 70px;','value'=>$tst['Memberplantext']['text'])); ?><?php  echo $this->Form->input("id",array('type'=>'hidden','value'=>$text['0']['Memberplantext']['id'])); ?></td></tr>
                        <?php $count++; endforeach; ?>    
			
		</tbody></table>
		<?php  
               
                echo $this->Form->end(array('class'=>'but','value'=>'SaveChages')); ?>
	</td>
    </tr>

</table>
